package com.example.sqldealtool.dealSqlToWord;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: xjc
 * @date: 2023/4/6 15:46
 **/
public interface TableMapper {
    /**
     *
     * @param TABLE_SCHEMA
     * @return
     */
    @Select("SELECT t.TABLE_NAME as tableName,t.TABLE_COMMENT as tableComment from information_schema.TABLES t WHERE t.TABLE_SCHEMA = #{TABLE_SCHEMA}")
    List<TableModel> getTables(String TABLE_SCHEMA);

    /**
     *
     * @param TABLE_SCHEMA
     * @param TABLE_NAME
     * @return
     */
    @Select("SELECT\n" +
            "    t.COLUMN_NAME AS name,\n" +
            "    t.COLUMN_COMMENT AS otherName,\n" +
            "    t.COLUMN_TYPE AS type,\n" +
            "    CASE t.IS_NULLABLE WHEN 'YES' THEN 'Y' ELSE 'N' END AS isNull,\n" +
            "    t.COLUMN_COMMENT AS comment\n" +
            "FROM information_schema.COLUMNS t \n" +
            "WHERE t.TABLE_SCHEMA=#{TABLE_SCHEMA}  AND t.TABLE_NAME=#{TABLE_NAME}")
    List<ColumnModel> getColumns(String TABLE_SCHEMA, String TABLE_NAME);


    @Select("SELECT result from eyedropper_task where id =3")
    String getBigJson();
}
